package com.deep.test.thread.concurrent;

/**
 * <p>Description:线程中断</p>
 * Created with IDEA
 * author:hudepin
 * createTime:2018/7/5 15:56
 */
public class Interrupted {
    public static void main(String[] args) {
        Thread sleepRunner = new Thread(new SleepRunner(),"SleepRunner");
        sleepRunner.setDaemon(true);
        Thread busyRunner = new Thread(new BusyRunner(),"BusyTunner");
        busyRunner.setDaemon(true);
        sleepRunner.start();
        busyRunner.start();
        SleepUtils.sleep(5);
        sleepRunner.interrupt();
        busyRunner.interrupt();
        System.out.println("sleepRunner:"+sleepRunner.isInterrupted());
        System.out.println("busyRunner:"+busyRunner.isInterrupted());
    }
    static class SleepRunner implements Runnable{

        @Override
        public void run() {
            while(true){
                SleepUtils.sleep(10);
            }

        }
    }
    static class BusyRunner implements Runnable{

        @Override
        public void run() {
            while(true){

            }
        }
    }
}
